<?php 
    $itemArr = get_posts( 
                            array(  'post_type' => 'post', 'numberposts' => -1, 
                                    'post_status' => 'publish', 'post_parent' => null,
                                    'category' => 'feature-products')
                        );
                            
    $exArr = array();
    
    foreach($itemArr as $item){
        $descriptionFe = $item->post_content;
       
        $ID = (int) $item->ID;
        
       // $link = get_post_meta($ID, 'url', true);
        $link = getREXG($descriptionFe , 'url');
        $link = ($link != '') ? $link :'#';
        $image = get_the_post_thumbnail($ID,'normal' );
        
        $descriptionFe = getREXG($descriptionFe ,'text');
        $exArr[] = array( 'des'=>$descriptionFe ,'img'=>$image,'url'=>$link);
    }
    /**
     * The function get data by Regular Expression
     * Type have 2 kinds: url or text within <a>Text</a>
     */ 
    function getREXG($input , $type){
        $regexp = "<a\s[^>]*href=(\"??)([^\" >]*?)\\1[^>]*>(.*)<\/a>"; 
        if(preg_match_all("/$regexp/siU", $input, $matches, PREG_SET_ORDER)) 
        { 
            if($type == 'url')
                return $matches[0][2];
            elseif($type == 'text')
                return $matches[0][3];
            else 
                return '';
            
        }  
    }
?>

<div class="banners">
    <div class="coin-slider">
    
    <?php if(count($exArr) > 0): ?>
        <div id="coin-slider">
	           <?php foreach($exArr as $each): ?>
                    <?php if($each['url'] == '#'): ?>
                        <a href="javascript:void(0);return false;" >
                    <?php else:?>
                        <a href="<?php echo $each['url'] ?>" >
                    <?php endif;?>
                        <?php echo $each['img'] ?> 
                        <span><?php echo $each['des'] ?></span>
                    </a>
               <?php endforeach; ?>
        </div>
    <?php endif; ?>
    </div>
</div>

<?php if(count($exArr) > 0): ?>
<script>
 	jQuery(document).ready(function() {
	    jQuery('#coin-slider').coinslider({ width: 638, navigation: false, delay: 5000 });
     });  
</script>
<?php endif; ?>